package com.wp.other;

import java.util.BitSet;

/**
 * Created by 王萍 on 2017/8/21 0021.
 */
public class BitMap {

    public static void main(String[] args) {
        BitSet bitSet = new BitSet();
        System.out.println("length is "+bitSet.length()+",and size is "+bitSet.size());
        bitSet.set(2);
        //length方法的返回值是最高设置为true的bit的索引+1。
        System.out.println("length is "+bitSet.length()+",and size is "+bitSet.size());
        System.out.println(bitSet.get(1));

        byte[] bytes = bitSet.toByteArray();
        for (byte b:bytes){
            System.out.println(b);
        }
    }
}
